using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using Entities;
using BUS;
using Utility;

public partial class Admin_DoanhNghiepUpdate : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        
        if (!IsPostBack)
        {
            LoadData();
        }

    }
    private void LoadData()
    {
        try
        {
            int iD = int.Parse(Request.QueryString["iD"].ToString());
            txt_madoanhnghiep.Text = iD.ToString();
            tbDoanhNghiep doanhnghiep = tbDoanhNghiepBUS.GetByID(iD);
            txt_tendoanhnghiep.Text=doanhnghiep .TenDN ;
            txt_diachi.Text=doanhnghiep .DiaChi ;
            txt_dienthoai.Text=doanhnghiep .DienThoai ;
            txt_email.Text = doanhnghiep.Email;
            txt_taikhoan.Text=doanhnghiep .TaiKhoan ;
            txt_matkhau.Text = doanhnghiep.MatKhau;
        }
        catch
        {
            Response.Redirect("~/Admin/DoanhNghiepDanhSach.aspx");
        }

    }


    protected void btn_sua_Click(object sender, EventArgs e)
    {
        try
        {
            int iD = int.Parse(Request.QueryString["iD"].ToString());
            tbDoanhNghiep doanhnghiep = tbDoanhNghiepBUS.GetByID(iD);
            doanhnghiep.TenDN = txt_tendoanhnghiep.Text;
            doanhnghiep.DiaChi = txt_diachi.Text;
            doanhnghiep.DienThoai = txt_dienthoai.Text;
            doanhnghiep.Email = txt_email.Text;
            doanhnghiep.TaiKhoan = txt_taikhoan.Text;
            doanhnghiep.MatKhau = txt_matkhau.Text;
            tbDoanhNghiepBUS.Update(doanhnghiep);
        }
        catch
        {
           
        }
        Response.Redirect("~/Admin/DoanhNghiepDanhSach.aspx");
        Response.Redirect(Request.RawUrl);
    }
}
